<script type="text/javascript">
    $(document).ready(function() {
        $("#example").dataTable();
    });

    function del(id) {
        if (confirm("คุณแน่ใจใช่ไหมที่ต้องการลบข้อมูลนี้")) {
            $.post("debtor_group_process.php", {task:'del', id: id }, function(data) {window.location.href = "index.php?pages=debtor_group";} )
        }
    }

    function edit(id) {
        
        window.location.href = "index.php?pages=debtor_group_edit&id=" + id;
    }
</script>

<?php
//include_once 'includes/connect.php';
//include_once 'includes/connect.php';
?>
<a href="index.php?pages=debtor_group_edit" class="btn primary" id="add_new">เพิ่มกลุ่มลูกหนี้</a>
<table id="example" class="table table-bordered dataTable">
    <caption><br></caption>
    <thead>
        <tr>
            <th>#</th>
            <th>กลุ่มลูกหนี้</th>
            <th>action</th>
        </tr>
    </thead>

    <tbody>
        <?php
        $db = new myDBS();

        $sql = "SELECT * "
                . " FROM tbl_debtor_group ";

        //echo $sql;
        $result = $db->runSQL($sql);

        while ($rows = $db->fetch_object($result)) {
            ?>
            <tr>
                <td><?php echo $rows->id; ?></td>
                <td><?php echo $rows->group_name; ?></td>
                <td><a href="javascript:edit(<?php echo $rows->id; ?>)"><i class="icon-pencil"></i></a>&nbsp;|&nbsp;<a href="javascript:del(<?php echo $rows->id; ?>)"><i class="icon-remove"></i></a></td>
            </tr>
            <?php
        }
        ?>
    </tbody></table>